 require "dbi" 

 class Connection
	
      # The block elements are the connection configurations.
      #  These will be used in establishing the relationship.
      def self.global_connection(localhost,root,password,database,database_type) 
          new_connection = Connection.connect do
                @host=localhost, 
                @username=root,
                @password=password,
                @database=database,
                @database_type=database_type
          end
          return new_connection
      end	
    
      # This is the actual connection method. 
      #  Based on the DBi the connection will be established with different databases.
      def self.connect(&b)
          connection_str = String.new
          block_elements = []
          block_elements = b.call
          new_connection = DBI.connect("DBI:#{block_elements.last.capitalize}:#{block_elements[3]}:#{block_elements[0]}", "#{block_elements[1]}", "#{block_elements[2]}")
          return new_connection
      end	
 end	